-- @owner: wan005
-- @date: 2024-11-06
-- @testpoint: smallint(n)作为对象名测试，部分合理报错

--pre1:切换B库执行
@conn PrimaryDbBmode;

--step1:作为列名 expect:成功
drop table if exists smallint_test cascade;
create table smallint_test(smallint smallint);
insert into smallint_test values('0');

--step2:作为索引名 expect:成功
create index on smallint_test(smallint);
drop table if exists smallint_test cascade;

--step3:作为表名 expect:成功
drop table if exists smallint cascade;
create table smallint(smallint smallint);
insert into smallint values('1');
select * from smallint;
drop table if exists smallint cascade;

--step4:作为数据库名 expect:成功
drop database if exists smallint;
create database smallint;
drop database smallint;

--step5:作为外部数据源名 expect:成功
drop data source if exists smallint;
create data source smallint;
drop data source smallint;

--step6:作为自定义函数名  expect:报错
create or replace function smallint(c1 smallint(666))
returns smallint(666)
as  $$
begin
    return c1;
end;
$$language plpgsql;
/

--step7:作为存储过程名 expect:报错
CREATE OR REPLACE PROCEDURE smallint(P1 IN smallint(666)) AS
BEGIN
insert into t_smallint_0023 values ('00001');
raise info '测试smallint作为存储过程名';
END;
/

--step8:作为角色名 expect:成功
drop role if exists smallint;
create role smallint with password 'gauss@123' valid until '2001-12-12';
drop role smallint;

--step9:作为用户组名 expect:成功
drop group if exists smallint;
create group smallint with password 'gauss@123';
drop group smallint;

--step10:作为模式名 expect:成功
drop schema if exists smallint;
create schema smallint;
drop schema smallint;

--step11:作为序列名 expect:成功
create sequence public.smallint start 100 cache 50;
drop sequence public.smallint;

--step12:作为用户名 expect:成功
drop user if exists smallint;
create user smallint password 'Bigdata@123';
drop user smallint;

--step13:前置条件 expect:成功
drop table if exists smallint_test cascade;
create table smallint_test(cid int,fid int);

--step14:作为游标名号-成功 expect:成功
start transaction;
cursor smallint for select * from smallint_test order by 1;
close smallint;
end;

--step15:清理环境 expect:成功
drop table if exists smallint_test cascade;